package com.gdth.utils;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import android.util.Log;

public class DownloadUtil {
	private static String TAG = "DownloadUtil";
	
	public static InputStream downloanFile(String urlPath) {
		InputStream in = null;
		try {
			URL url = new URL(urlPath);
			HttpURLConnection httpURLconnection = (HttpURLConnection) url.openConnection();
			httpURLconnection.setDoInput(true);
			httpURLconnection.connect();
			if (httpURLconnection.getResponseCode() == 200) {
				in = httpURLconnection.getInputStream();
			} else {
				Log.e(TAG, "下载图片失败，状态码是：" + httpURLconnection.getResponseCode());
			}
		} catch (Exception e) {
			Log.e(TAG, "下载图片失败，原因是：" + e.toString());
			e.printStackTrace();
		}
		
		return in;
	}
}
